// physics.h : contains the definition of the physics component, 
// which is responsible for all physics collisions between objects
//$Id: Physics.h 25 2009-08-21 02:02:10Z brwarner2 $
#pragma once

#include "Component.h"

//Physics component class
class CPhysics : public IComponent
{
public:
	CPhysics(void);
	virtual ~CPhysics(void);

	//Initialization function
	void Init( const ParameterList &params );

	//Component ID
	static const ComponentID COMPONENT_ID = 4;

	//Game monkey registration function
	static void RegisterGM( gmMachine* );

	//Handler for GM function calls
	int GMCall( gmThread*, const std::string& name );

	//Gets the component ID
	ComponentID GetComponentID(void) { return COMPONENT_ID; }

	//Factory function
	static IComponent* Factory(void) { return new CPhysics(); }

	//Destruct function
	static void Destruct( IComponent* pPhys ) { delete (pPhys); }

	//Width function
	float Width(void) { return m_width; }

	//Height function
	float Height(void) { return m_height; }

	//Depth function
	float Depth(void) { return m_depth; }

	//Message function
	void Message( MessageID message, const boost::any& arg = 0 );

	//Collision rectangle
	struct Rect
	{
		float left, right, top, bottom;
	};
private:
	//Size information
	float m_width, m_height, m_depth;

	//Creates a rect from a physics entity
	static Rect CreateRect( CPhysics* pPhys, const bug::math::CVector& pos );

	//Intersect
	static bool Intersect( const Rect&, const Rect& );
};